package main

import (
	"fmt"
)

func utf8(c int) {
	switch {
	case (c < 0x80):
		putchar(c)

	case (c < 0x800):
		putchar(0xC0 | c>>6)
		putchar(0x80 | c&0x3F)

	case (c < 0x10000):
		putchar(0xE0 | c>>12)
		putchar(0x80 | c>>6&0x3F)
		putchar(0x80 | c&0x3F)

	case (c < 0x200000):
		putchar(0xF0 | c>>18)
		putchar(0x80 | c>>12&0x3F)
		putchar(0x80 | c>>6&0x3F)
		putchar(0x80 | c&0x3F)
	}
}

func putchar(c int) {
	//fmt.Printf("%b ", c)
	fmt.Printf("%x ", c)
}

func main() {
	utf8(131)
}
